package com.weiyun.controller;

import com.weiyun.common.R;
import com.weiyun.pojo.Food;
import com.weiyun.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/***
 *   @Author:weiyun
 *
 */
@RestController
@RequestMapping("/food")
@CrossOrigin
public class FoodController {
    @Autowired
    private FoodService foodService;
    //根据商家id获取对应id
    @GetMapping("/listFoodByBusinessId/{businessId}")
    public R listFoodByBusinessId(@PathVariable String businessId) {
        try {
            List<Food> foods = foodService.listFoodByBusinessId(Integer.valueOf(businessId));
            return R.ok().data(foods);

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
